<?php
/**
 * 工具函数库
 * @author wangXi <iwisunny@gmail.com>
 * Date: 2015/12/1 11:37
 */

/**
 * 获取用户端ip
 * @return string
 */
function get_user_ip(){
    $ip = '';
    if( !empty( $_SERVER[ "HTTP_CLIENT_IP" ] ) ) {
        $ip = $_SERVER[ "HTTP_CLIENT_IP" ];
    }
    else if( !empty( $_SERVER[ "HTTP_X_FORWARDED_FOR" ] ) ) {
        $ip = $_SERVER[ "HTTP_X_FORWARDED_FOR" ];
    }
    else {
        $ip = $_SERVER[ "REMOTE_ADDR" ];
    }

    return $ip;
}